import { adminUserIds } from '@/config';
import api from '@/services/organization/subsidiary-base-management';

export type SubsidiaryBase = SubsidiaryBaseManagementApi.InfoResponse;

export const getAllList = async () => {
  const res = await api.getAllList<SubsidiaryBase[]>();
  return res.data;
};
export const getAllSelectList = async () => {
  const res = await api.getAllSelectList<SubsidiaryBase[]>();
  return res.data;
};
/** 根据用户ID 判断请求列表接口 */
export const getSelectList = async (userId: string = '') => {
  return adminUserIds.includes(userId) ? getAllList() : getAllSelectList();
};
export const create = async (params: SubsidiaryBaseManagementApi.CreateParams) => {
  const data = await api.create(params);
  return data;
};
export const update = async (params: SubsidiaryBaseManagementApi.UpdateParams) => {
  const data = await api.update(params);
  return data;
};
export const remove = async (params: SubsidiaryBaseManagementApi.DeleteParams) => {
  const data = await api.remove(params);
  return data;
};
export default {
  getAllList,
  getAllSelectList,
  getSelectList,
  create,
  update,
  remove,
};
